package com.sjz.han.industry.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.sjz.han.industry.MainActivity;
import com.sjz.han.industry.R;


/**
 * Created by wzl on 2018/05/04.
 * <p>私密对话框
 * 最后更新 2018/05/04
 */

public class PaytDialog extends Dialog implements View.OnClickListener {

    private Context context;
    private LinearLayout null_partll,pay_zfb_ll,pay_wx_ll;
    private OnItemClickLicener onItemClickLicener;

    public PaytDialog(Context context) {
        super(context, R.style.dialog2);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_pay_view);
        Window dialogWindow = this.getWindow();
        dialogWindow.getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams layoutParams = dialogWindow.getAttributes();
// 设置宽度
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        dialogWindow.setAttributes(layoutParams);
        dialogWindow.setGravity(Gravity.BOTTOM);
        dialogWindow.setWindowAnimations(R.style.send_photo_anim_style);
        ImageView tv_del_cancle = (ImageView) findViewById(R.id.bt_cancel);
        null_partll = (LinearLayout) findViewById(R.id.null_partll);
        tv_del_cancle.setOnClickListener(this);
        null_partll.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                dismiss();
                return true;
            }
        });

        pay_zfb_ll=(LinearLayout)this.findViewById(R.id.pay_zfb_ll);
        pay_wx_ll=(LinearLayout)this.findViewById(R.id.pay_wx_ll);
        pay_zfb_ll.setOnClickListener(this);
        pay_wx_ll.setOnClickListener(this);
    }



    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_cancel:
                dismiss();
                break;
            case R.id.pay_zfb_ll://支付宝支付
                if(onItemClickLicener!=null){
                    onItemClickLicener.toZfbPay();
                }
                this.dismiss();
//               context.startActivity(new Intent(context, MainActivity.class));
                break;
            case R.id.pay_wx_ll://微信支付
                if(onItemClickLicener!=null){
                    onItemClickLicener.toWxPay();
                }
                this.dismiss();
//                context.startActivity(new Intent(context, MainActivity.class));
                break;

        }

    }

    public interface OnItemClickLicener {
        void toWxPay();

        void toZfbPay();
    }

    public void setOnItemClickLicener(OnItemClickLicener onItemClickLicener) {
        this.onItemClickLicener = onItemClickLicener;
    }

}
